// Service ControlDlg.h : header file
//

#if !defined(AFX_SERVICECONTROLDLG_H__3B585BC7_8B36_11D5_9785_0002E315D226__INCLUDED_)
#define AFX_SERVICECONTROLDLG_H__3B585BC7_8B36_11D5_9785_0002E315D226__INCLUDED_

#include "casbase.h"	// Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "winsvc.h"

class CServiceControlDlgAutoProxy;

/////////////////////////////////////////////////////////////////////////////
// CServiceControlDlg dialog

class CServiceControlDlg : public CDialog
{
	DECLARE_DYNAMIC(CServiceControlDlg);
	friend class CServiceControlDlgAutoProxy;

// Construction
public:
	bool SortTextItems(int nCol, bool bAscending, int low, int high);
	CString m_csBaseName;
	CServiceControlDlg(CWnd* pParent = NULL);	// standard constructor
	virtual ~CServiceControlDlg();

    void SetLogLevel(CString ServiceName);

// Dialog Data
	//{{AFX_DATA(CServiceControlDlg)
	enum { IDD = IDD_SERVICECONTROL_DIALOG };
	CListCtrl	m_LCServiceList;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CServiceControlDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CServiceControlDlgAutoProxy* m_pAutoProxy;
	HICON m_hIcon;

	BOOL CanExit();

	// Generated message map functions
	//{{AFX_MSG(CServiceControlDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnClose();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnDblclkLservicelist(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnColumnclickLservicelist(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnBtnstartall();
	afx_msg void OnBtnstopall();
	afx_msg void OnItemChangedInList(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBtnsetstopmsg();
	afx_msg void OnBtnstart();
	afx_msg void OnBtnstop();
	afx_msg void OnBtnkill();
	afx_msg void OnBtnkillall();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	void KillAllServices();
	void KillByShortName(CString csShortName);
	int GetProcessId(CString csShortName);
	int m_iLastFocusIndex;
	bool m_bSortAscending;
	void SetFocusOnly(int nFocusIndex);
	int m_iFocusIndex;
	void StopMsgWindow(int nItemIndex);
	void SetStopMsg(CString csShortName, CString csStopMsg);
	int GetIndex(CString csShortName);
	void SetButtonStates();
	bool m_bStarting;
	void StopAll();
	void StartAll();
	void StopServiceByName(CString csShortName);
	void StartServiceByName(CString csShortName);
	UINT m_uRefreshTimer;
	UINT StartTimer(UINT uDuration);
	int m_iSortedCol;
	bool m_bCanSetStopMsg;
	bool m_bIsOneStoppable;
	bool m_bIsOneStartable;
	void UpdateAll();
	CString GetStopMsg(CString csServiceName);
	CString GetUserCountCS(CString csServiceName);
	void GetItemFromName(CString csShortName, LVITEM* plvi);
	void UpdateSingleItem(CString csShortName, CString csAppName);
	CString MakeServiceName(CString csShortName);
	CString MakeAppName(CString csShortName);
	CString MakeFullName(CString csShortName);
	CString StripCasinoName(CString csServiceName);
	CString StripAppName(CString csServiceName);
	#define MAX_SERVICE_COUNT 50
	CString m_pcaServices[MAX_SERVICE_COUNT];
	CString m_pcaServicesShortName[MAX_SERVICE_COUNT];
	CString m_pcaServicesAppName[MAX_SERVICE_COUNT];
	int m_iaLastFocus[MAX_SERVICE_COUNT];
	int m_iNumServices;
	void SetWindowTitle();
	void GetServiceList();

	bool m_bKillPossible;
	SC_HANDLE openSCM();
	SC_HANDLE openSvc(SC_HANDLE hSCM, LPCTSTR serviceName);
public:

	afx_msg void OnCbnSelchangeCombologlevel();
//	afx_msg void OnCbnDropdownCombologlevel();
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SERVICECONTROLDLG_H__3B585BC7_8B36_11D5_9785_0002E315D226__INCLUDED_)
